package com.mmd.utils;

import java.io.File;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class CheckMainTaskServer {
	private static Logger LOGGER = LoggerFactory.getLogger(CheckMainTaskServer.class);

	/** 需要扫描的配置文件，按顺序直到找到第一个为止 */
	private static final String[] confPaths = new String[] { "/etc/isMainTask", "/root/isMainTask",
			"C:/isMainTask.txt", "D:/isMainTask.txt", "F:/isMainTask.txt" };

	/**
	 * 检测是否是主任务服务器
	 * 
	 * @return
	 */
	public static boolean isMainTaskServer() {
		if (confPaths == null) {
			LOGGER.info("is not main task server! so task is over.");
			return false;
		}
		for (String filePath : confPaths) {
			File file = new File(filePath);
			if (file.exists() && file.isFile()) {
				LOGGER.info("this is main task server!so task is run.");
				return true;
			}
		}
		return false;
	}

	public static void main(String[] args) {
		System.out.println(isMainTaskServer());
	}
}
